﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebMobie.Models;
using WebMobie.Models.Entities;
using WebMobie.Modules.Query;

namespace WebMobie.Controllers
{
    public class AdminController : Controller
    {
	    private readonly WebMobileContext db = new WebMobileContext();
        //
        // GET: /Admin/

	[Authorize(Roles = "Admin")]
        public ActionResult Index()
        {
            return View();
        }

		[Authorize(Roles = "Admin")]
	    public ActionResult ManageUser()
	    {
		    ViewBag.category = Defines.CATEGORY_NV;
		    return View();
	    }


        [HttpGet]
        public ActionResult StatisticsDoanhSo(int id)
        {
            /*
            string[] arr = { "2013", " 2013" };
            ViewData["username"] = arr;
            ViewBag.Year = id;
            int[] Doanhthu = { 199,209, 234, 400, 500, 120,156, 190, 210, 280, 290, 320 };
            ViewBag.dt = Doanhthu;
             * */
            var listKetQua = getDoanhThuTheoNam(id);
            ViewBag.listKetQua = listKetQua;
            ViewBag.Year = id;
			ViewBag.hideVertical = 1;
            return View();
        }

        public ActionResult StatisticsSanPham()
        {
            string[] sanpham = { "a1", "a2", "a3", "a4", "a5" };
            ViewBag.sanpham = sanpham;
            int[] soluong1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 };
            int[] soluong2 = { 11, 21, 31, 41, 51, 61, 41, 23, 55, 77, 11, 21 };
            int[] soluong3 = { 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42 };
            int[] soluong4 = { 41, 42, 43, 44, 45, 46, 47, 48, 49, 60, 61, 62 };
            int[] soluong5 = { 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62 };
           
            ViewBag.soluong2 = soluong2;
            ViewBag.soluong3 = soluong3;
            ViewBag.soluong4 = soluong4;
            ViewBag.soluong5 = soluong5;

			ViewBag.hideVertical = 1;
           
            return View();
        }

        public List<decimal> getDoanhThuTheoNam(int year)
        {
            List<decimal> listResult = new List<decimal>();
            for (int i = 1; i <= 12; i++)
            {
                decimal iTotal = db.getDoanhThuTheo(i, year);
                listResult.Add(iTotal);

            }
            return listResult;
        }

	// @Tin: kiem tra don hang
		[Authorize(Roles = "Sale")]
		public ActionResult CheckOrder()
		{
			ViewBag.category = Defines.CATEGORY_DUYET;
			ViewBag.hideVertical = 1;
			return View();
		}
		//@Tin: hoan tat don hang
		[Authorize(Roles = "Sale")]
		public ActionResult FinishOrder()
		{
			ViewBag.category = Defines.CATEGORY_FINISH;
			ViewBag.hideVertical = 1;
			return View();
		}

	    public ActionResult viewOrder()
	    {
			ViewBag.category = Defines.CATEGORY_VIEWORDER;
			ViewBag.hideVertical = 1;
			return View();
	    }
    }
}
